from time import sleep

from selenium import webdriver
from selenium.webdriver.common.by import By

class UserCart():
    def __init__(self,driver):
        self.driver=driver
    def upl(self):
        self.driver.find_element(By.ID,'q').send_keys('手机')
        sleep(1)
        self.driver.find_element(By.CLASS_NAME,'search_usercenter_btn').click()

    def add_goods(self):
        self.driver.find_element(By.CLASS_NAME,'lazy-list').click()
        self.driver.find_element(By.ID,'join_cart').click()

    def cart_good_message(self):
        frame = self.driver.find_element(By.ID, 'layui-layer-iframe1')
        self.driver.switch_to.frame(frame)
        result = self.driver.find_element(By.XPATH, '//span[text()="添加成功"]').text
        return result
        # self.driver.quit()